Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit 0f2d3b06c2bb02d0a096c896b21f6f52100b3eb8


Parents : 3f91e44
Author : Mark Qvist <mark@unsigned.io>
Date : 2025-10-30T15:18:09+01:00

Also receive PN path response announces, but only update peering data on live announces

Changes

1 files changed, 49 insertions(+), 48 deletions(-)

M LXMF/Handlers.py +49 -48

Diff

diff --git a/LXMF/Handlers.py b/LXMF/Handlers.py
index e1dba8e..793ba16 100644
--- a/LXMF/Handlers.py
+++ b/LXMF/Handlers.py
@@ -35,53 +35,54 @@ class LXMFDeliveryAnnounceHandler:
class LXMFPropagationAnnounceHandler:
def __init__(self, lxmrouter):
self.aspect_filter = APP_NAME+".propagation"
- self.receive_path_responses = False
+ self.receive_path_responses = True
self.lxmrouter = lxmrouter
- def received_announce(self, destination_hash, announced_identity, app_data):
- try:
- if type(app_data) == bytes:
- if self.lxmrouter.propagation_node:
- data = msgpack.unpackb(app_data)
- if pn_announce_data_is_valid(data):
- node_timebase = data[1]
- propagation_transfer_limit = None
- propagation_sync_limit = None
- wanted_inbound_peers = None
- if len(data) >= 5:
- try: propagation_sync_limit = int(data[4])
- except Exception as e: propagation_sync_limit = None
-
- if len(data) >= 4:
- # TODO: Rethink, probably not necessary anymore
- # try: wanted_inbound_peers = int(data[3])
- # except: wanted_inbound_peers = None
- pass
-
- if len(data) >= 3:
- try: propagation_transfer_limit = float(data[2])
- except: propagation_transfer_limit = None
-
- if destination_hash in self.lxmrouter.static_peers:
- self.lxmrouter.peer(destination_hash=destination_hash,
- timestamp=node_timebase,
- propagation_transfer_limit=propagation_transfer_limit,
- propagation_sync_limit=propagation_sync_limit,
- wanted_inbound_peers=wanted_inbound_peers)
-
- else:
- if self.lxmrouter.autopeer:
- if data[0] == True:
- if RNS.Transport.hops_to(destination_hash) <= self.lxmrouter.autopeer_maxdepth:
- self.lxmrouter.peer(destination_hash=destination_hash,
- timestamp=node_timebase,
- propagation_transfer_limit=propagation_transfer_limit,
- propagation_sync_limit=propagation_sync_limit,
- wanted_inbound_peers=wanted_inbound_peers)
-
- elif data[0] == False:
- self.lxmrouter.unpeer(destination_hash, node_timebase)
-
- except Exception as e:
- RNS.log("Error while evaluating propagation node announce, ignoring announce.", RNS.LOG_DEBUG)
- RNS.log("The contained exception was: "+str(e), RNS.LOG_DEBUG)
+ def received_announce(self, destination_hash, announced_identity, app_data, announce_packet_hash, is_path_response):
+ if not is_path_response:
+ try:
+ if type(app_data) == bytes:
+ if self.lxmrouter.propagation_node:
+ data = msgpack.unpackb(app_data)
+ if pn_announce_data_is_valid(data):
+ node_timebase = data[1]
+ propagation_transfer_limit = None
+ propagation_sync_limit = None
+ wanted_inbound_peers = None
+ if len(data) >= 5:
+ try: propagation_sync_limit = int(data[4])
+ except Exception as e: propagation_sync_limit = None
+
+ if len(data) >= 4:
+ # TODO: Rethink, probably not necessary anymore
+ # try: wanted_inbound_peers = int(data[3])
+ # except: wanted_inbound_peers = None
+ pass
+
+ if len(data) >= 3:
+ try: propagation_transfer_limit = float(data[2])
+ except: propagation_transfer_limit = None
+
+ if destination_hash in self.lxmrouter.static_peers:
+ self.lxmrouter.peer(destination_hash=destination_hash,
+ timestamp=node_timebase,
+ propagation_transfer_limit=propagation_transfer_limit,
+ propagation_sync_limit=propagation_sync_limit,
+ wanted_inbound_peers=wanted_inbound_peers)
+
+ else:
+ if self.lxmrouter.autopeer:
+ if data[0] == True:
+ if RNS.Transport.hops_to(destination_hash) <= self.lxmrouter.autopeer_maxdepth:
+ self.lxmrouter.peer(destination_hash=destination_hash,
+ timestamp=node_timebase,
+ propagation_transfer_limit=propagation_transfer_limit,
+ propagation_sync_limit=propagation_sync_limit,
+ wanted_inbound_peers=wanted_inbound_peers)
+
+ elif data[0] == False:
+ self.lxmrouter.unpeer(destination_hash, node_timebase)
+
+ except Exception as e:
+ RNS.log("Error while evaluating propagation node announce, ignoring announce.", RNS.LOG_DEBUG)
+ RNS.log("The contained exception was: "+str(e), RNS.LOG_DEBUG)


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────